<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Eder
 */
class ConfigurarParametrosBO extends GeneralSisResBO{
    
    var $medicoDao;
    var $horarioDao;
    var $tipoTarjetaDao;
    var $opcionDao;
    var $className;

    public function __construct() {
        $this->className = 'ConfigurarParametrosBO';
        LogUtil::info("class $this->className", "__construct");
        $this->medicoDao = DAOFactory::getMedicoDao();
        $this->horarioDao = DAOFactory::getHorarioDao();
        $this->tipoTarjetaDao = DAOFactory::getTipoTarjetaDao(); 
        $this->opcionDao = DAOFactory::getOpcionDao(); 
   }

    public function __destruct() {
        LogUtil::info("class $this->className", "__destruct");
    }       
    
    public function guardarMedico($medico) {
       LogUtil::info("class $this->className", "guardarMedico");  
       try{           
           Transaction::beginTransaction();           
           $id = $this->medicoDao->guardarMedico($medico);   
           LogUtil::debug("class $this->className", "inserto el medico de id:".$id);
           Transaction::commitTransaction();                      
       }catch(Exception $e){
           Transaction::rollbackTransaction();
           LogUtil::info("class $this->className", $e->getMessage());
           throw new Exception($e->getMessage(), $e->getCode());
       }
       return $id;
    }
    
    public function actualizarMedico($medico) {
       LogUtil::info("class $this->className", "actualizarMedico");  
       try{           
           Transaction::beginTransaction();           
           $retorno = $this->medicoDao->actualizarMedico($medico);
           LogUtil::debug("class $this->className", "update el medico: ".$retorno);
           Transaction::commitTransaction();                      
       }catch(Exception $e){
           Transaction::rollbackTransaction();
           LogUtil::info("class $this->className", $e->getMessage());
           throw new Exception($e->getMessage(), $e->getCode());
       }
       return $retorno;
    }
    
    //horario      
    
    public function guardarHorario($horario) {
       LogUtil::info("class $this->className", "guardarHorario");  
       try{           
           Transaction::beginTransaction();           
           $id = $this->horarioDao->guardarHorario($horario);
           LogUtil::debug("class $this->className", "inserto el horario de id:".$id);
           Transaction::commitTransaction();                      
       }catch(Exception $e){
           Transaction::rollbackTransaction();
           LogUtil::info("class $this->className", $e->getMessage());
           throw new Exception($e->getMessage(), $e->getCode());
       }
       return $id;
    }
    
    public function actualizarHorario($horario) {
       LogUtil::info("class $this->className", "actualizarHorario");  
       try{           
           Transaction::beginTransaction();           
           $retorno = $this->horarioDao->actualizarHorario($horario);
           LogUtil::debug("class $this->className", "update el horario: ".$retorno);
           Transaction::commitTransaction();                      
       }catch(Exception $e){
           Transaction::rollbackTransaction();
           LogUtil::info("class $this->className", $e->getMessage());
           throw new Exception($e->getMessage(), $e->getCode());
       }
       return $retorno;
    }
    
    public function actualizarOpcion($opcion) {
       LogUtil::info("class $this->className", "actualizarOpcion");  
       try{           
           Transaction::beginTransaction();           
           $retorno = $this->opcionDao->actualizarOpcion($opcion);
           Transaction::commitTransaction();                      
       }catch(Exception $e){
           Transaction::rollbackTransaction();
           LogUtil::info("class $this->className", $e->getMessage());
           throw new Exception($e->getMessage(), $e->getCode());
       }
       return $retorno;
    }
    

}
?>
